<?php
// Module Definition
$module['name'] = 'MailMan';
$module['description'] = 'Provides mailman mailing list functionality.';

switch($action) {
	case 'register':
		// Table structure for table `mailman`
		$SQL =
		"CREATE TABLE IF NOT EXISTS `mailman` (
		  id tinyint(4) NOT NULL auto_increment,
		  domain bigint(10) NOT NULL default '0',
		  listname varchar(25) NOT NULL default '',
		  admin varchar(255) NOT NULL default '',
		  password blob NOT NULL,
		  action char(1) NOT NULL default '',
		  PRIMARY KEY  (id)
		) TYPE=MyISAM";
		$res = mysql_query($SQL);
		return $res;
		break;
	case 'unregister':
		$SQL = 'DELETE FROM properties WHERE name = "mm" AND user = "mm"';
		$res = mysql_query($SQL);
		$SQL = "DROP TABLE IF EXISTS `mailman`";
		$res = mysql_query($SQL);
		return $res;
		break;
	case 'enable':
		break;
	case 'disable':
		break;
	case 'hook':
		register_hook('web:menu', 'mailman_add_menu');
		register_hook('web:lang', 'mailman_add_lang');
		register_hook('web:cfg:default', 'mailman_add_cfg');

		register_hook('server:cfg:default', 'mailman_add_cfg');
		register_hook('server:maillist:sendmail:generate', 'mailman_sendmail_generate');
		register_hook('server:maillist:update', 'mailman_update');
        register_hook('server:apache:virthost', 'mailman_generate_host_conf');
        register_hook('web:server:templates', 'mailman_template');

		register_hook('web:server:newaccount:table', 'mailman_reseller_settings');

		register_hook('web:reseller:resellerset:table', 'mailman_reseller_settings');
		register_hook('web:reseller:resellerinfo:table', 'mailman_get_infotable');
		register_hook('web:reseller:newdomain:table', 'mailman_domain_settings');
		register_hook('fetchdata:reseller:mm', 'mailman_fetch');
		register_hook('fetchdata:reseller:*', 'mailman_fetch');
		register_hook('web:reseller:create', 'mailman_set');
		register_hook('web:reseller:update', 'mailman_set');
		register_hook('web:reseller:update:check', 'mailman_check');

		register_hook('fetchdata:total:mm', 'mailman_fetch_total');
		register_hook('fetchdata:total:*', 'mailman_fetch_total');
		register_hook('fetchdata:alloc:mm', 'mailman_fetch_alloc');
		register_hook('fetchdata:alloc:*', 'mailman_fetch_alloc');

		register_hook('web:domain:domainset:table', 'mailman_domain_settings');
		register_hook('web:domain:domaininfo:table', 'mailman_get_infotable');
		register_hook('fetchdata:domain:mm', 'mailman_fetch');
		register_hook('fetchdata:domain:*', 'mailman_fetch');
		register_hook('web:domain:create', 'mailman_set');
		register_hook('web:domain:create:check', 'mailman_domain_check');
		register_hook('web:domain:update', 'mailman_set');
		register_hook('web:domain:update:check', 'mailman_domain_check');
		register_hook('web:domain:mailman', 'mailman_domain_manage');
		break;
}
?>